'use strict';
/**
 * Created by FreezeSoul on 2015/9/30.
 */
define([
        'angular',
        'app/modules/page/define',
        'app/modules/page/services/page'
    ],
    function(angular) {
        angular.module('ad.page')
            .controller('adPageExportController',['$scope','$uibModalInstance','adPageEditService','item',function($scope,$uibModalInstance,service,item) {
                $scope.item = item;

                $scope.downloadLink = undefined;

                $scope.ok = function () {
                    if ($scope.item.page_id) {
                        service.exportPage($scope.item.page_id).then(function (data) {
                            var obj = angular.fromJson(data);
                            if (obj.result == 'success') {
                                $scope.downloadLink = adConfig.baseServiceUrl + obj.data;
                            }
                        });
                    }
                };

                $scope.cancel = function () {
                    $uibModalInstance.dismiss('cancel');
                };
            }]);
    });